"""Outback URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
# from django.contrib import admin
from django.conf.urls import url
from django.urls import path, include
from rest_framework.authtoken import views
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter
from rest_framework.documentation import include_docs_urls

import xadmin
from commando.views import ProblemListViewSet, AnswerViewSet, TagViewSet, CommentViewSet
from operation.views import FollowProblemViewSet, FavAnswerViewSet, AgreeOppositeAnswerViewSet, ProblemToTagViewSet, \
    FollowUserViewSet
from users.views import SmsCodeViewSet, UserViewSet
from trade.views import AlipayView

router = DefaultRouter()

router.register('problems', ProblemListViewSet, base_name='problems')
router.register('answers', AnswerViewSet, base_name='answers')
router.register('follow-problems', FollowProblemViewSet, base_name='follow_problems')
router.register('fav-answers', FavAnswerViewSet, base_name='fav_answers')  # 收藏回答
router.register('agree-opposite', AgreeOppositeAnswerViewSet, base_name='agree_opposite')  # 赞同回答
router.register('tags', TagViewSet, base_name='tags')  # 标签
router.register('problem-tags', ProblemToTagViewSet, base_name='problem_tags')  # 问题的标签设置
router.register('codes', SmsCodeViewSet, base_name='codes')  # 验证码
router.register('comments', CommentViewSet, base_name='comments')  # 评论
router.register('users', UserViewSet, base_name='comments')  # 用户注册
router.register('follow-user', FollowUserViewSet, base_name='follow_user')  # 用户注册

urlpatterns = [
    path('admin/', xadmin.site.urls),
    path('docs/', include_docs_urls(title="Outbackd在线文档")),
    url(r'^login/', include('rest_framework.urls', namespace='login')),

    url(r'^', include(router.urls)),
    url(r'^api-token-auth/', views.obtain_auth_token),  # django自带的token认证
    url(r'^jwt-auth/', obtain_jwt_token),  # jwt的认证
    url(r'alipay/return', AlipayView.as_view(), name='alipay'),
    url('', include('social_django.urls', namespace='social')),  # 第三方登录
]
